Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Update example app #172

Merged
merged 13 commits into from
Feb 29, 2024
Merged

refactor: Update example app #172

merged 13 commits into from
Feb 29, 2024

Conversation

Mercy811
Copy link
Contributor

@Mercy811 Mercy811 commented Feb 28, 2024

  • Update example app to use the new APIs. Layout is the same as previous.
  • Update Flutter min version from 2.12.0 to 2.15.0 in order to support name property of Enum
    • Segment min version is 2.19.2. So I feel it's ok to higher it.
  • Note app life cycle events are not tracked. Have a separate ticket for it.
image

Click all button and can see requests being sent successfully.
image

Click to see paylaods!
Payload 1 ``` { "api_key": "5b9a9510e261f9ead90865bbc5a7ad1d", "client_upload_time": "2024-02-28T21:00:08.325Z", "events": [ { "event_type": "Dart Click", "user_id": "Xinyi", "device_id": "Xinyi's pixel", "time": 1709153978106, "event_properties": {}, "user_properties": {}, "groups": {}, "group_properties": {}, "platform": "Android", "os_name": "android", "os_version": "12", "device_brand": "google", "device_manufacturer": "Google", "device_model": "sdk_gphone64_arm64", "carrier": "T-Mobile", "language": "en", "ip": "$remote", "version_name": "1.0", "event_id": 4, "session_id": 1709153875403, "insert_id": "d744e8fb-a73c-4581-85dd-a706b1f6c0f3", "library": "amplitude-analytics-android\/1.14.0" }, { "event_type": "$identify", "user_id": "Xinyi", "device_id": "Xinyi's pixel", "time": 1709154000792, "event_properties": {}, "user_properties": { "$set": { "identify_test": "identify sent at 1709154000791", "key": "value" }, "$add": { "identify_count": 1 } }, "groups": {}, "group_properties": {}, "platform": "Android", "os_name": "android", "os_version": "12", "device_brand": "google", "device_manufacturer": "Google", "device_model": "sdk_gphone64_arm64", "carrier": "T-Mobile", "language": "en", "ip": "$remote", "version_name": "1.0", "event_id": 5, "session_id": 1709153875403, "insert_id": "af1cb155-453b-4e6b-8ee0-8665e76837ee", "library": "amplitude-analytics-android\/1.14.0" }, { "event_type": "$identify", "user_id": "Xinyi", "device_id": "Xinyi's pixel", "time": 1709154004792, "event_properties": {}, "user_properties": { "$set": { "account": "acme" } }, "groups": { "account": "acme" }, "group_properties": {}, "platform": "Android", "os_name": "android", "os_version": "12", "device_brand": "google", "device_manufacturer": "Google", "device_model": "sdk_gphone64_arm64", "carrier": "T-Mobile", "language": "en", "ip": "$remote", "version_name": "1.0", "event_id": 6, "session_id": 1709153875403, "insert_id": "cf8e4d2e-efde-477a-8f9d-597b7a555ef6", "library": "amplitude-analytics-android\/1.14.0" } ] } ```
Payload 2 ``` { "api_key": "5b9a9510e261f9ead90865bbc5a7ad1d", "client_upload_time": "2024-02-28T21:00:19.784Z", "events": [ { "event_type": "$groupidentify", "user_id": "Xinyi", "device_id": "Xinyi's pixel", "time": 1709154015994, "event_properties": {}, "user_properties": {}, "groups": { "account": "acme" }, "group_properties": { "$set": { "group key": "group value" } }, "platform": "Android", "os_name": "android", "os_version": "12", "device_brand": "google", "device_manufacturer": "Google", "device_model": "sdk_gphone64_arm64", "carrier": "T-Mobile", "language": "en", "ip": "$remote", "version_name": "1.0", "event_id": 7, "session_id": 1709153875403, "insert_id": "bb783b51-38ee-4332-8d76-0b2fe869d6af", "library": "amplitude-analytics-android\/1.14.0" }, { "event_type": "revenue_amount", "user_id": "Xinyi", "device_id": "Xinyi's pixel", "time": 1709154017846, "event_properties": { "$productId": "specialProduct", "$quantity": 2, "$price": 41.23 }, "user_properties": {}, "groups": {}, "group_properties": {}, "platform": "Android", "os_name": "android", "os_version": "12", "device_brand": "google", "device_manufacturer": "Google", "device_model": "sdk_gphone64_arm64", "carrier": "T-Mobile", "language": "en", "ip": "$remote", "version_name": "1.0", "event_id": 8, "session_id": 1709153875403, "insert_id": "acd17c54-f017-4eaa-8bd3-b8ef24bf11cd", "library": "amplitude-analytics-android\/1.14.0" } ] } ```

@Mercy811 Mercy811 marked this pull request as ready for review February 28, 2024 19:56
@@ -27,6 +27,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace 'com.example.amplitude_flutte_example'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: flutter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Update in 5c4ad59

@@ -50,7 +40,7 @@ class Amplitude extends _Amplitude {
event.mergeEventOptions(options);
}

return await _channel.invokeMethod("track", jsonEncode(event.toMap()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is jsonEncode not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsonEncode() is what our Flutter SDK used before. But one big problem with JSON string is that, in the Android plugin, getString() casts null to a string "null". invokeMethod() accepts both String and Map data type. So I believe it's easier to get the value at client side and also to debug.

@yuhao900914
Copy link
Contributor

yuhao900914 commented Feb 28, 2024

Other questions:

  1. why the branch is v4.x?
  2. we'd better show the min support version, like the flutter version in the dev doc.
  3. do we still need to support flutter web?

example/lib/main.dart Outdated Show resolved Hide resolved
@Mercy811
Copy link
Contributor Author

Mercy811 commented Feb 28, 2024

@yuhao900914

why the branch is v4.x?

In case we need to release fix version for current Flutter SDK while developing the new Flutter SDK. Will merge v4.x into main with a breaking change.

we'd better show the min support version, like the flutter version in the dev doc.

Could you elaborate on it? How and where to show it? I didn't find anything related it min version in dev doc.

do we still need to support flutter web?

The pre-release version will not support web.

@Mercy811 Mercy811 requested a review from yuhao900914 February 28, 2024 23:14
@yuhao900914
Copy link
Contributor

@Mercy811
Copy link
Contributor Author

Thanks @yuhao900914, I updated readme at 24780f7

@Mercy811 Mercy811 merged commit ceb8915 into v4.x Feb 29, 2024
2 checks passed
@Mercy811 Mercy811 deleted the AMP-89883-update-example-app branch February 29, 2024 19:06
Copy link

🎉 This PR is included in version 4.0.0-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants